package leetcode.code2140;

import leetcode.IDebug;

public class Solution implements IDebug {

	int[][] q;
	int len;

	public long mostPoints(int[][] questions) {
		q = questions;
		len = questions.length;
		Long[] dp = new Long[len];
		return find(0, dp);
	}

	private long find(int index, Long[] dp) {
		if (index >= len) {
			return 0;
		}
		if (dp[index] != null) {
			return dp[index];
		}
		int[] question = q[index];
		long pointsi = question[0];
		int brainpoweri = question[1];
		long ans = pointsi + this.find(index + brainpoweri + 1, dp);
		ans = Math.max(ans, this.find(index + 1, dp));
		dp[index] = ans;
		return ans;
	}

	@Override
	public void debug4() {
		// TODO Auto-generated method stub

	}

	@Override
	public void debug3() {
		// TODO Auto-generated method stub

	}

	@Override
	public void debug2() {
		// TODO Auto-generated method stub

	}

	@Override
	public void debug1() {
		// TODO Auto-generated method stub

	}

	public static void main(String[] args) {
		// TODO Auto-generated method stub

	}

}
